<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">文章编辑</ui:define>
    <ui:define name="content">
        <h:form enctype="multipart/form-data">
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                    	<p:commandButton value="预览" icon="fa fa-save"
                        				 ajax="false"
                                         actionListener="#{healthHeadlineInfoBean.onPreview(healthHeadlineInfoBean.$.id)}"
                                         update="@form"/>
                        <p:commandButton value="编辑" icon="fa fa-edit"
                                         actionListener="#{healthHeadlineInfoBean.changeStatusToEdit}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{healthHeadlineInfoBean.isView() and security:areAllGranted('LOAN_FAMILY_TAGS_FIRST_PARTY_EDIT')}"/>
                        <p:commandButton value="保存" icon="fa fa-save"
                                         actionListener="#{healthHeadlineInfoBean.onSave}"
                                         rendered="#{healthHeadlineInfoBean.isNotView() and security:areAnyGranted('LOAN_FAMILY_TAGS_FIRST_PARTY_EDIT,LOAN_FAMILY_TAGS_FIRST_PARTY_ADD')}"
                                         update="@form"/>
                        <p:commandButton value="取消" icon="fa fa-reply"
                                         actionListener="#{healthHeadlineInfoBean.changeStatusToView}"
                                         rendered="#{healthHeadlineInfoBean.isEdit()}"
                                         process="@this"
                                         update="@form"/>
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12 card">
                    <div class="card">
                    	<div class="ui-g-12"><h3><b>基本信息</b></h3></div>
							<div class="ui-g-2">
                                <p:outputLabel for="title" value="文章标题"/>
                            </div>
                            <div class="ui-g-4">
                                <p:inputText id="title" value="#{healthHeadlineInfoBean.$.title}"
                                             disabled="#{healthHeadlineInfoBean.isView()}"/>
                            </div>
							<div class="ui-g-2">
                                <p:outputLabel for="reader" value="已读人数"/>
                            </div>
                            <div class="ui-g-4">
                                <p:inputText id="reader" value="#{healthHeadlineInfoBean.$.reader}"
                                             disabled="#{healthHeadlineInfoBean.isView()}"/>
							</div>
							<div class="ui-g-2">
                                <p:outputLabel for="sourceName" value="文章来源"/>
                            </div>
                            <div class="ui-g-4">
                                <p:inputText id="sourceName" value="#{healthHeadlineInfoBean.$.sourceName}"
                                             disabled="#{healthHeadlineInfoBean.isView()}" readonly="true"/>
                            </div>
                            <div class="ui-g-2">              
                                <p:outputLabel for="onlineStatus" value="文章状态"/>
                            </div>
                            <div class="ui-g-4">
						        <p:selectOneRadio id="onlineStatus" value="#{healthHeadlineInfoBean.$.onlineStatus}"
					                               disabled="#{healthHeadlineInfoBean.isView()}">
					                <f:selectItem itemLabel="未上线" itemValue="0"/>
                                   	<f:selectItem itemLabel="已上线" itemValue="1"/>
						        </p:selectOneRadio>
						    </div>   
						    <div class="ui-g-2"> 
						        <p:outputLabel for="recommendStatus" value="推荐状态"/>
						    </div>
						    <div class="ui-g-4">
						        <p:selectOneRadio id="recommendStatus" value="#{healthHeadlineInfoBean.$.recommendStatus}"
					                               disabled="#{healthHeadlineInfoBean.isView()}">
					                <f:selectItem itemLabel="不推荐" itemValue="0"/>
                                   	<f:selectItem itemLabel="推荐" itemValue="1"/>
						        </p:selectOneRadio>
							</div> 
							
							<div class="ui-g-2"> 
						        <p:outputLabel for="recommendStatus" value="推荐时间"/>
						    </div>
                            <div class="ui-g-4">
                            	<p:calendar id="recommendTime" value="#{healthHeadlineInfoBean.$.recommendTime}"
                            	 			disabled="#{healthHeadlineInfoBean.isView()}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"/>
                            </div>
                            
                            <div class="ui-g-12"><h3><b>作用小程序（多选）</b></h3></div>
						    <div class="ui-g-12">
					            <p:selectManyButton value="#{healthHeadlineInfoBean.$.selectedMiniAppsList}"
					                                disabled="#{healthHeadlineInfoBean.isView()}">
					                <f:selectItems value="#{healthHeadlineInfoBean.allMiniAppsList}"
					                               var="apps"
					                               itemLabel="#{apps.relationName}"
					                               itemValue="#{apps.id}"/>
					            </p:selectManyButton>
					        </div>
					        
					        <div class="ui-g-12"><h3><b>作用标签（多选）</b></h3></div>
                            <div class="ui-g-12">
					            <p:selectManyButton value="#{healthHeadlineInfoBean.$.selectedTabList}"
					                                disabled="#{healthHeadlineInfoBean.isView()}">
					                <f:selectItems value="#{healthHeadlineInfoBean.allTabList}"
					                               var="apps"
					                               itemLabel="#{apps.relationName}"
					                               itemValue="#{apps.id}"/>
					            </p:selectManyButton>
					        </div>
					        
					        <div class="ui-g-12"><h3><b>图片配置</b></h3></div>
					        <div class="ui-g-2">              
                                <p:outputLabel for="onlineStatus" value="推荐主图"/>
                            </div>
                            <div class="ui-g-2">
					            <p:graphicImage url="#{healthHeadlineInfoBean.$.recommendMainImage.uploadUrl}" width="120"/>
					        </div>
					        <div class="ui-g-2">
					            <p:fileUpload fileUploadListener="#{healthHeadlineInfoBean.onUploadRecommendMainImage}"
					                          mode="advanced"
					                          fileLimit="1"
					                          auto="true"
					                          fileLimitMessage="只能上传一个文件"
					                          label="上传" update="@form" process="@form" disabled="#{healthHeadlineInfoBean.isView()}"/>
					        </div>
					        
					        <div class="ui-g-12"><h3><b>文章内容编辑</b></h3></div>
					        <div class="ui-g-2">
						        <p:outputLabel value="文章正文（编辑器）"/>
						    </div>
						    <div class="ui-g-10">
						        <p:inputTextarea value="#{healthHeadlineInfoBean.$.content}" rows="16"/>
						    </div>
						    <div class="ui-g-2">
						        <p:outputLabel value="正文配图"/>
						    </div>
						    <div class="ui-g-10">
					            <p:fileUpload fileUploadListener="#{healthHeadlineInfoBean.onUploadContextConfImage}"
					                          mode="advanced"
					                          fileLimit="1"
					                          auto="true"
					                          fileLimitMessage="只能上传一个文件"
					                          label="上传" update="@form" process="@form" disabled="#{healthHeadlineInfoBean.isView()}"/>
						    	
						    	<p:repeat value="#{healthHeadlineInfoBean.$.contentImgList}" var="img">
							    	<p:commandLink oncomplete="PF('imgDialog').show()" actionListener="#{healthHeadlineInfoBean.onCopyMedia(img)}">
								        <p:graphicImage url="#{img.uploadUrl}" alt="" title=""/>
								    </p:commandLink> 
								    <p:inputText value="#{img.uploadUrlHtmlTab}"
                                             disabled="#{healthHeadlineInfoBean.isView()}" readonly="true"/>  
							    </p:repeat>
						    </div>
						    
						    <div class="ui-g-2">
						        <p:outputLabel value="正文配视频"/>
						    </div>
						    <div class="ui-g-10">
						    	<div class="ui-g-10">
						    		<p:fileUpload fileUploadListener="#{healthHeadlineInfoBean.onUploadContextConfVideo}"
					                          mode="advanced"
					                          fileLimit="1"
					                          auto="true"
					                          fileLimitMessage="只能上传一个文件"
					                          label="上传" update="@form" process="@form" disabled="#{healthHeadlineInfoBean.isView()}"/>
						    	</div>
						        <p:repeat value="#{healthHeadlineInfoBean.$.contentVideoList}" var="video">
						        	<div class="ui-g-2">
								        <p:outputLabel value="视频链接："/>
								    </div>
						        	<div class="ui-g-8">
							    		<p:inputText value="#{video.uploadUrlHtmlTab}"
	                                            disabled="#{healthHeadlineInfoBean.isView()}" readonly="true"/>
	                                </div>
							    </p:repeat>
						    </div>
                    </div>
                </div>
            </div>
        </h:form>
        
        <p:dialog header="配图链接"  widgetVar="imgDialog" modal="true" showEffect="blind" hideEffect="explode" resizable="false">
        <p:outputPanel id="carDetail" style="text-align:center;">
        	<f:facet name="header">
                <p:graphicImage name="healthHeadlineInfoBean.$.copyMedia.uploadUrl"/> 
            </f:facet>

            <h:outputText value="原始链接" />
            <h:outputText value="#{healthHeadlineInfoBean.$.copyMedia.originalUrl}" />

            <h:outputText value="最新链接" />
            <h:outputText value="#{healthHeadlineInfoBean.$.copyMedia.uploadUrl}" />
        </p:outputPanel>
    </p:dialog>
        
        
    </ui:define>
</ui:composition>











